package com.sparrow.common.buff.effect;

import com.sparrow.common.buff.context.BuffContext;
import com.sparrow.common.buff.domain.Buff;
import com.sparrow.common.buff.domain.IBuffActor;
import com.sparrow.common.buff.domain.IBuffEffectParam;

public abstract class AbstractBuffEffect implements IBuffEffect {

    private IBuffEffectParam effectParam;

    @Override
    public void onStart(Buff buff) {

    }

    @Override
    public void onExpire(Buff buff) {

    }

    @Override
    public void onTick(Buff buff, long now) {

    }

    @Override
    public void onRefresh(Buff buff) {

    }

    @Override
    public void setBuffEffectParam(IBuffEffectParam param) {
        this.effectParam = param;
    }

    @Override
    public <T extends IBuffEffectParam> T getEffectParam() {
        return (T) effectParam;
    }

    public <T extends IBuffActor> T getSource(Buff buff) {
        BuffContext buffContext = buff.getBuffContext();
        T t = (T) buffContext.getSource();
        return t;
    }

    public <T extends IBuffActor> T getTarget(Buff buff) {
        BuffContext buffContext = buff.getBuffContext();
        T t = (T) buffContext.getTarget();
        return t;
    }
}
